//
//  RenHouseHomeListCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/12/19.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "RenHouseHomeListCell.h"

@interface RenHouseHomeListCell ()
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;

@property (weak, nonatomic) IBOutlet UILabel *topLabel;
@property (weak, nonatomic) IBOutlet UILabel *middleLabel;

@property (weak, nonatomic) IBOutlet UILabel *priceLabel;

@property (weak, nonatomic) IBOutlet UILabel *markLabelOne;
@property (weak, nonatomic) IBOutlet UILabel *markLabelTwo;
@property (weak, nonatomic) IBOutlet UILabel *markLabelThree;
@property (weak, nonatomic) IBOutlet UILabel *bottomLabel;
@property (weak, nonatomic) IBOutlet UILabel *markLabelFour;

@end

@implementation RenHouseHomeListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.topLabel.font = MYFONT(17);
    
    self.middleLabel.font = MYFONT(13);
    
    self.middleLabel.textColor = darkGray;
    
    self.priceLabel.font = MYFONT(15);
    
    
    self.bottomLabel.font = MYFONT(13);
    
    self.priceLabel.textColor = [UIColor orangeColor];
    
    self.markLabelOne.font = MYFONT(13);
    
    self.markLabelTwo.font = MYFONT(13);
    
    self.markLabelThree.font = MYFONT(13);
    
    self.markLabelFour.font = MYFONT(13);

    
    self.markLabelThree.textColor = colorWith(26, 90, 198);
    self.markLabelTwo.textColor = colorWith(26, 90, 198);
    self.markLabelOne.textColor = [UIColor whiteColor];
    self.markLabelFour.textColor = colorWith(26, 90, 198);

    self.markLabelThree.backgroundColor = colorWith(228, 244, 253);
    self.markLabelTwo.backgroundColor = colorWith(228, 244, 253);
    self.markLabelOne.backgroundColor = colorWith(225, 180, 86);
    self.markLabelFour.backgroundColor = colorWith(228, 244, 253);

    self.markLabelThree.layer.cornerRadius = 5;
    self.markLabelTwo.layer.cornerRadius = 5;
    self.markLabelOne.layer.cornerRadius = 5;
    self.markLabelFour.layer.cornerRadius = 5;

    self.markLabelThree.layer.masksToBounds = YES;
    self.markLabelTwo.layer.masksToBounds = YES;
    self.markLabelOne.layer.masksToBounds = YES;
    self.markLabelFour.layer.masksToBounds = YES;

    self.markLabelThree.hidden = YES;
    self.markLabelFour.hidden = YES;
    
    
//    
//    [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1514010704&di=0f09494e2273b2f46a36a8d23a3585af&imgtype=jpg&er=1&src=http%3A%2F%2Fstatic-xiaoguotu.17house.com%2F000%2F038%2F201405161502186093.jpg"] placeholderImage:nil];
    // Initialization code
}


- (void)setModel:(HouseParameterModel *)model{
    
    _model = model;
    
    
    [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:_model.house_pic] placeholderImage:nil];
    
    self.topLabel.text = _model.house_title;
    
    self.middleLabel.attributedText = [self attributedString];
    
//    self.markLabelTwo.text = [NSString stringWithFormat:@" %@ ",_model.house_language_name];
    
    if (_model.house_language_names.count == 1) {
        self.markLabelTwo.hidden = NO;
        self.markLabelThree.hidden = YES;
        self.markLabelFour.hidden = YES;
        
        self.markLabelTwo.text =  [NSString stringWithFormat:@" %@ ",_model.house_language_names.firstObject];
        
        
    } else if (_model.house_language_names.count == 2){
        
        self.markLabelTwo.hidden = NO;
        self.markLabelThree.hidden = NO;
        self.markLabelFour.hidden = YES;
        self.markLabelTwo.text =  [NSString stringWithFormat:@" %@ ",_model.house_language_names.firstObject];
        
        self.markLabelThree.text =  [NSString stringWithFormat:@" %@ ",_model.house_language_names.lastObject];
        
    }else{
        
        self.markLabelTwo.hidden = NO;
        self.markLabelThree.hidden = NO;
        self.markLabelFour.hidden = NO;
        
        self.markLabelTwo.text =  [NSString stringWithFormat:@" %@ ",_model.house_language_names.firstObject];
        
        self.markLabelThree.text =  [NSString stringWithFormat:@" %@ ",_model.house_language_names[1]];
        
        
        self.markLabelFour.text =  [NSString stringWithFormat:@" %@ ",_model.house_language_names.lastObject];
        
    }
    
    
    self.priceLabel.text = [NSString stringWithFormat:@"%@/月",_model.house_price];
    
    self.bottomLabel.text = _model.area;
    
    
}

//self.middleLabel.text = [NSString stringWithFormat:@"%@/%@m2/%@",_model.house_decorate_name,_model.house_area,_model.house_face_name];


- (NSMutableAttributedString *)attributedString{
    
    UIFont *bigFont = MYFONT(13);
    //    UIFont *smallFont = MYFONT(7);
    NSMutableAttributedString *attributeString6 = [[NSMutableAttributedString alloc] init];
    
    NSAttributedString *string26 = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@/%@m",_model.house_decorate_name,_model.house_area] attributes:@{NSFontAttributeName : bigFont,NSForegroundColorAttributeName : darkGray,NSBaselineOffsetAttributeName : @(0)}];
    
    
    NSAttributedString *string27 = [[NSAttributedString alloc] initWithString:@"2" attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:7],NSForegroundColorAttributeName : darkGray,NSBaselineOffsetAttributeName : @(8)}];
    
    NSAttributedString *string28 = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"/%@",_model.house_face_name] attributes:@{NSFontAttributeName : bigFont,NSForegroundColorAttributeName : darkGray,NSBaselineOffsetAttributeName : @(0)}];
    
    
    
    [attributeString6 appendAttributedString:string26];
    [attributeString6 appendAttributedString:string27];
    [attributeString6 appendAttributedString:string28];
    
    return attributeString6;
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
